package com.sangeng.ss.service.impl;

import com.sangeng.ss.domain.DogEvent;
import com.sangeng.ss.service.TestEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author ：xxx
 * @description：TODO
 * @date ：2024/04/01 16:05
 */
@Service
@Slf4j
public class TestEventImpl implements TestEvent, ApplicationListener<DogEvent> {
    @Override
    public void listenerEvent1(DogEvent dogEvent) {
        log.info(dogEvent.getSource() + "1111111");
    }


    @Override
    public void listenerEvent(DogEvent dogEvent) {
        log.info(dogEvent.getSource()+"");
    }


    @Override
    @Async
    public void onApplicationEvent(DogEvent dogEvent) {
        log.info(dogEvent.getSource()+ "睡前异步的");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info(dogEvent.getSource()+ "睡后异步的");
    }
}
